package cn.jsoup;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;
import java.io.IOException;

public class jsoupDemo2 {
    public static void main(String[] args) throws IOException {
        /*
        parse:解析html和xml文档,返回Document
         */
        String path = jsoupDemo2.class.getClassLoader().getResource("student.xml").getPath();
        Document document1 = Jsoup.parse(new File("D:\\Ultimate IDEA\\myXML\\out\\production\\Jsoup_Using\\student.xml"), "utf-8");
        System.out.println(document1);

        System.out.println("-----------------");
        Document document2 = Jsoup.parse("<!--?xml version=\"1.0\" encoding=\"utf-8\" ?-->\n" +
                "<html>\n" +
                " <head></head>\n" +
                " <body>\n" +
                "  <studnets> \n" +
                "   <student id=\"01\"> \n" +
                "    <name>\n" +
                "     zhangsan\n" +
                "    </name> \n" +
                "    <age>\n" +
                "     18\n" +
                "    </age> \n" +
                "    <sex>\n" +
                "     male\n" +
                "    </sex> \n" +
                "   </student> \n" +
                "   <student id=\"02\"> \n" +
                "    <name>\n" +
                "     lisi\n" +
                "    </name> \n" +
                "    <age>\n" +
                "     19\n" +
                "    </age> \n" +
                "    <sex>\n" +
                "     female\n" +
                "    </sex> \n" +
                "   </student> \n" +
                "  </studnets>\n" +
                " </body>\n" +
                "</html>");
        System.out.println(document2);

        System.out.println("------------------");
        Document document3 = Jsoup.parse("https://www.baidu.com/");
        System.out.println(document3);
    }
}
